﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.guide.actions {
    import Engine.Classes.*;
    import flash.utils.*;
    import Classes.*;
    import GameMode.*;

    public class GAGameModePlayFiltered extends GuideAction {

        protected var m_classes:Array;
        protected var m_itemNames:Array;

        public function GAGameModePlayFiltered(){
            this.m_classes = new Array();
            this.m_itemNames = new Array();
            super();
        }
        override public function createFromXml(_arg1:XML):Boolean{
            var inclXML:* = null;
            var className:* = null;
            var def:* = null;
            var xml:* = _arg1;
            var incl:* = checkAndGetElement(xml, "include");
            if (!incl){
                return (false);
            };
            for each (inclXML in incl) {
                className = inclXML.@className;
                if (((!((className == null))) && (!((className == ""))))){
                    try {
                        def = getDefinitionByName(("Classes." + className));
                        this.m_classes.push((def as Class));
                    } catch(e:Error) {
                        return (false);
                    };
                };
                if (String(inclXML.@itemName) != ""){
                    this.m_itemNames.push(String(inclXML.@itemName));
                };
            };
            return (true);
        }
        override public function update(_arg1:Number):void{
            super.update(_arg1);
            Global.world.addGameMode(new GMPlayFiltered(this.testWorldObject));
            removeState(this);
        }
        protected function testWorldObject(_arg1:WorldObject):Boolean{
            var _local3:Class;
            var _local4:String;
            var _local2:Boolean;
            if (((!((this.m_classes == null))) && ((this.m_classes.length > 0)))){
                for each (_local3 in this.m_classes) {
                    if ((_arg1 is _local3)){
                        _local2 = true;
                        break;
                    };
                };
            } else {
                if (((!((this.m_itemNames == null))) && ((this.m_itemNames.length > 0)))){
                    for each (_local4 in this.m_itemNames) {
                        if ((((_arg1 is MapResource)) && (((_arg1 as MapResource).getItemName() == _local4)))){
                            _local2 = true;
                            break;
                        };
                    };
                };
            };
            return (_local2);
        }

    }
}//package Modules.guide.actions 
